<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<link href="css/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="js/jquery-1.6.2.min.js"></script>
<script src="js/jquery-ui-1.8.16.js"></script>
<script src="js/sabrina.js"></script>
<html>
<head>
<title><tiles:insertAttribute name="title" /></title>
<script>
	var incomingParam = window.dialogArguments;
		
	var selectedIds = new Array();
	var selectedNames = new Array();
	var ret = [selectedIds,selectedNames];
	
	function setv(id, name) {
		prepare(id, name);
		ok();
	}
	function prepare(id, name) {
		//alert(id+", "+name);
		var cb = document.getElementById("checkbox"+id);
		
		if(cb.checked){
			selectedIds.push(id);
			selectedNames.push(name);
		} else {
			var index = 0;
			for(i=0;i<selectedIds.length;i++){
				if(selectedIds[i]==id){
					index = i;
					break;
				}
			}
			selectedIds.splice(index,1);
			selectedNames.splice(index,1);
		}
		refreshSelectedValues();
	}
	
	
	function ok() {
		parent.callback(ret);
		parent.$('div[id^="dialog"]').dialog( "close" );
	}
	function cancel() {
		parent.$('div[id^="dialog"]').dialog( "close" );
	}
	
	
	/////1,2,3
	
	function person(id){
		selectedIds[2]=id;
		selectedNames[2]=getName("person");
		refreshSelectedValues();
	}
	function award(id){
		selectedIds[1]=id;
		selectedNames[1]=getName("award");
		refreshSelectedValues();
	}
	function calendar(id){
		selectedIds[0]=id;
		selectedNames[0]=getName("calendar");
		refreshSelectedValues();
	}
	function typev(id){
		selectedIds[3]=id;
		selectedNames[3]=getName("type");
		refreshSelectedValues();
	}
	
	
	/////1,2,3
	
	function mpr_r(id){
		selectedIds[0]=id;
		selectedNames[0]=getName("role");
		refreshSelectedValues();
	}
	function mpr_p(id){
		selectedIds[1]=id;
		selectedNames[1]=getName("person");
		refreshSelectedValues();
	}
	function getName(elementId){
		var obj=document.getElementById(elementId);
		var name = obj.options[obj.options.selectedIndex].innerText; 
		return name;
	}
	
	
	function refreshSelectedValues(){
		var v = document.getElementById("selected");
		v.value=selectedNames;
	}
	
</script>
<link rel="stylesheet" href="css/default.css" type="text/css" />
</head>
<body topmargin="0" leftmargin="0" bgcolor="white">
<table width="100%" border="0" align="center">
	
	<tr>
		<td valign="top" height="30px">
			<tiles:insertAttribute name="title" />
		</td>
	</tr>
	<tr>
		<td valign="top"  style="border: 1px green solid;">
			<div style="overflow: auto;height: 320px;width: 100%;">
				<tiles:insertAttribute name="body" />
			</div>
		</td>
	</tr>
	<tr>
		<td valign="top" style="border: 1px green solid;"><input id="selected" type="text" size="86" /></td>
	</tr>
	<tr>
		<td align="right"><input id="ok" type="button" value="   Ok   " onclick="ok()" /> <INPUT type="button" value=" Cancel " onclick="cancel()"></td>
	</tr>
</table>
</body>
</html>